package com.syezon.wifikey.base;


import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.view.View;

import com.syezon.wifikey.analysis.AnalysisHelper;
import com.syezon.wifikey.analysis.ui.UmengAnalysisAppCompatActivity;
import com.syezon.android.base.eventbus.EventCenter;
import com.syezon.android.base.netstatus.NetUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2018/9/5.
 */

public abstract class BaseActivity extends UmengAnalysisAppCompatActivity {

    private RxPermissions permissions;

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            handleMessage(msg);
        }
    };

    public Handler getHandler() {
        return mHandler;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        permissions = new RxPermissions(this);
        //PushAgent.getInstance(this).onAppStart();
        super.onCreate(savedInstanceState);
    }

    protected void requestPermission(final PermissionCallBack callBack, final String... permission) {
        permissions.request(permission).subscribe(new Observer<Boolean>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Boolean aBoolean) {
                callBack.onResult(aBoolean, permission);
            }

            @Override
            public void onError(Throwable e) {
                AnalysisHelper.reportError(e);
            }

            @Override
            public void onComplete() {

            }
        });
    }

    protected void handleMessage(Message message) {
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return TransitionMode.NONE;
    }


    @Override
    protected boolean toggleOverridePendingTransition() {
        return true;
    }


    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void onEventComming(EventCenter eventCenter) {
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return true;
    }

}
